package com.farsight.leo.fssmartlock.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * Author: Administrator
 * Date: 2019/9/17
 * Project: SmartLockApp
 * Description:
 */
public class DateUtils {

    private static SimpleDateFormat rfc1123DateTimeFormatter = new SimpleDateFormat("EEE, dd LLL yyyy HH:mm:ss z", Locale.US);
    private static SimpleDateFormat outputDateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss", Locale.US);
    //2019.09.17 09:40:57

    private DateUtils() {
    }

    //Wed, 18 Sep 2019 01:11:49 GMT
    public static long parseRFC1123DateTimeToLong(String rfc_1123_date_time) throws ParseException {
        Date date = rfc1123DateTimeFormatter.parse(rfc_1123_date_time);
        return date.getTime();
    }

    public static String parseLongToOutputTimeFormat(long date) {
        return outputDateFormat.format(new Date(date));
    }

    public static long parseDefaultTimeFormatToLong(String defaultTimeFormat) throws ParseException {
        Date date = outputDateFormat.parse(defaultTimeFormat);
        return date.getTime();
    }


}
